import winreg
import ctypes
import os

# 验证权限
if not ctypes.windll.shell32.IsUserAnAdmin():
    exit()

# 全局设置
steamRoot = "D:\steam"
userlist = []
userDataPath = steamRoot + "\config\loginusers.vdf"

with open (userDataPath) as fp:
    for eachline in fp:
        if(eachline[:15]=='\t\t"AccountName"'):
            userlist.append(eachline.split('"')[3])


# 选择用户
for i,j in enumerate(userlist):
    print(i,j)

a = int(input("用户"))

os.system("test.bat")

reg = winreg.OpenKey(winreg.HKEY_CURRENT_USER,r"SOFTWARE\Valve\Steam",access=winreg.KEY_ALL_ACCESS)
winreg.SetValueEx(reg , "AutoLoginUser",0, winreg.REG_SZ,userlist[a])
winreg.CloseKey(reg)
os.system(steamRoot+"\steam.exe")



